#include "port3deditor.h"
#include "propertytreedockwidget.h"
#include "sourcesdock.h"
#include "datatypedefine.h"
#include <QComboBox>

void Port3DEditor::initializationMenuState()
{
	actionSaveFile->setEnabled(false);
	actionSaveAsFile->setEnabled(false);
	actionImportFiles->setEnabled(false);
	actionSettingReferencePoint->setEnabled(false);
	actionUndo->setEnabled(false);
	actionRedo->setEnabled(false);
	actionDel->setEnabled(false);
	actionEnvironmentSetting->setEnabled(false);
	actionAllObjectsSceneMode->setEnabled(false);
	actionEnableGrid->setEnabled(false);
	actionAddObscured->setEnabled(false);
	actionOperationRotation->setEnabled(false);
	actionaFreesurround->setEnabled(false);
	actionRemark->setEnabled(false);
	actionAddArea->setEnabled(false);
	actionEditArea->setEnabled(false);
	actionGroupToArea->setEnabled(false);
	actionShowHideArea->setEnabled(false);
	actionShowCollisionShape->setEnabled(false);
	actionAddCollisionShape->setEnabled(false);
	actionAddAsCameraAnimationAtt->setEnabled(false);
	actionPreviewCameraAnimation->setEnabled(false);
	actionSetCameraAnimationDockWidget->setEnabled(false);
	actionSetAsRoamStart->setEnabled(false);
	actionRoamPreview->setEnabled(false);
	_objectComboBox->setEnabled(false);
	actionPoorerWater->setEnabled(false);
	actionOnOffSoundDraw->setEnabled(false);
	actionAddLine->setEnabled(false);
	actionAddFreeFlag->setEnabled(false);
	actionGuideMapSetting->setEnabled(false);
	actionSourcesCreateSetting->setEnabled(false);
	actionFogSetting->setEnabled(false);
//	actionVerticalView->setEnabled (false);
//
//	actionSetCameraStart->setEnabled (false);
//
//	actionWebServiceSetting->setEnabled(false);
//	actionNewMarkLayer->setEnabled(false);
//	actionCompass->setEnabled(false);
//	 actionCollisionDetection->setEnabled (false);
//	 actionHideMeasure->setEnabled (false);
//	 actionDelCompass->setEnabled(false);
	_propertyDock->setDisabled(true);
	_sourceDock->setDisabled(true);
}

void Port3DEditor::menuStateChangeAfterNewOrOpenSuccess()
{
	actionSaveFile->setEnabled(true);
	actionSaveAsFile->setEnabled(true);
	actionImportFiles->setEnabled(true);
	actionEnvironmentSetting->setEnabled(true);
	_propertyDock->setDisabled(false);
	_sourceDock->setDisabled(false);
	actionEnableGrid->setEnabled(true);
	actionAddObscured->setEnabled(true);
	actionaFreesurround->setEnabled(true);
	actionRemark->setEnabled(true);
	actionAddArea->setEnabled(true);
	actionEditArea->setEnabled(true);
	actionGroupToArea->setEnabled(true);
	actionShowHideArea->setEnabled(true);
	actionShowCollisionShape->setEnabled(true);
	actionAddCollisionShape->setEnabled(true);
	actionAddAsCameraAnimationAtt->setEnabled(true);
	actionPreviewCameraAnimation->setEnabled(true);
	actionSetCameraAnimationDockWidget->setEnabled(true);
	actionSetAsRoamStart->setEnabled(true);
	actionRoamPreview->setEnabled(true);
	_objectComboBox->setEnabled(true);
	actionPoorerWater->setEnabled(true);
	actionOnOffSoundDraw->setEnabled(true);
	actionAddLine->setEnabled(true);
	actionAddFreeFlag->setEnabled(true);
	actionGuideMapSetting->setEnabled(true);
	actionSourcesCreateSetting->setEnabled(true);
	actionFogSetting->setEnabled(true);
}

void Port3DEditor::slotObjectSelectionChanged(QVector<QString> objecttypes)
{
	if(objecttypes.size() == 1)
	{
		actionDel->setEnabled(true);
		actionOperationRotation->setEnabled(true);
	}
	else if(objecttypes.size() > 1)
	{
		actionDel->setEnabled(true);
		actionOperationRotation->setEnabled(true);
	}
	else
	{
		actionDel->setEnabled(false);
		actionOperationRotation->setEnabled(false);
	}
}

void Port3DEditor::slotChangeActionState(int action,int state)
{
	bool enable = state==2?true:false;;
	switch (action)
	{
	case ACTION_UNDO_EVENT:
		actionUndo->setEnabled(enable);
		break;
	case ACTION_REDO_EVENT:
		actionRedo->setEnabled(enable);
		break;
	default:
		break;
	}
}